﻿using System.Collections.Generic;
using Security;
using Storage;
using System.Linq;
using Storage.EntityModels;
using System.Web.Security;

public class FriendsFromSNDataSource
{
    private string snName;
    private List<string> snUsers;
    private Security.TripLoaUser currentUser;

    public FriendsFromSNDataSource(string snName, List<string> snUsers, Security.TripLoaUser currentUser)
    {
        this.snName = snName;
        this.snUsers = snUsers;
        this.currentUser = currentUser;
    }

    public List<Security.Profile> Friends
    {
        get
        {
            return currentUser.GetFriendsIdFromSNExcludingBuddies(snName,snUsers,currentUser.UserID);


            //Test Code
            //StorageManager sm = StorageManager.Instance;

            //MembershipUser UserSecurity = Membership.GetUser();
            //TripLoaUser us = TripLoaUserManager._instance.getUser(UserSecurity.UserName);

            //Profile u1 = us.GetProfile("esn1");
            ////TripLoaUser u2 = Security.TripLoaUserManager._instance.getUser("Mask");
            ////TripLoaUser u3 = Security.TripLoaUserManager._instance.getUser("Stem");
            //return new List<Security.Profile> {
            //    u1 //, 
            //    //u2.GetProfile(), 
            //    //u3.GetProfile() 
            //};
        }
    }

    //private List<Profile> getFriendsIdFromSNExcludingBuddies(string social_network, List<string> friends, int userId)
    //{
    //    //var db = StorageManager.Instance.Entities;

    //    //var currUser = (from u in db.Users where u.Id == userId select u).First();

    //    //var userBuddies = from bud in db.BuddyLists where bud.Buddy == currUser select bud.Buddy;


    //    //var snFriends = from account in db.SocialNetworkSubscribeDetails
    //    //                where account.SocialNetwork.Name == social_network
    //    //                && friends.Contains(account.UserToken)
    //    //                select account.User;

    //    //var result = from r in snFriends.Except(userBuddies) select r.Id;

    //    //List<Profile> profiles = new List<Profile>();

    //    //List<int> friends_ids = result.ToList();

    //    //foreach (int id in friends_ids)
    //    //    profiles.Add(currentUser.GetProfile(id, PrivacyLevel.High));

    //    //return profiles;



        
    //}

}